home *** CD-ROM | disk | FTP | other *** search
-
-
-
- TECHNICAL INFO ON DOING SEND / RECEIVE FOR IBM-PC
-
-
- Here are some functions for doing low-level serial io on the IBM PC.
-
- struct regval { unsigned int ax,bx,cx,dx,si,di,ds,es; } ;
- #define COM1 0
- #define COM2 1
-
- /*
- send: send a character to a COM1
-
- returns:
- The value of the character sent or
- EOF if an error occurred
- */
- send(ch)
- char ch;
- {
- struct regval srv;
-
- srv.ax = 0x100 | (ch & 0xff); /* ah = 1, al = ch */
- srv.dx = COM1; /* select COM1 */
- sysint(0x14,&srv,&srv); /* send it */
- if(srv.ax & 0x8000) return EOF; /* an error occurred */
- return ch; /* no error occurred */
- }
-
-
- /*
- recv: wait until a character is ready at COM1 and return it
- Returns: the character received
- */
- recv()
- {
- struct regval srv;
-
- do { /* try to receive it */
- srv.ax = 0x200; /* select function */
- srv.dx = COM1; /* select COM1 */
- sysint(0x14,&srv,&srv); /* try to get it */
- }
- while (srv.ax & 0xff00); /* it's not ready yet */
- return (srv.ax & 0xff); /* return the character */
- }
-
-